home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / System / Shutdown FX / Shutdown FX ƒ / sfx code ƒ / sfx init.c < prev    next >
C/C++ Source or Header  |  1993-11-13  |  2KB  |  85 lines

  1. /**********************************************************************\
  2.  
  3. File:        sfx init.c
  4.  
  5. Purpose:    This module handles INIT initialization and installation.
  6.             
  7.  
  8. Shutdown FX -=- graphic effects on shutdown
  9. Copyright (C) 1993 Mark Pilgrim & Dave Blumenthal
  10.  
  11. This program is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation; either version 2 of the License, or
  14. (at your option) any later version.
  15.  
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. GNU General Public License for more details.
  20.  
  21. You should have received a copy of the GNU General Public License
  22. along with this program in a file named "GNU General Public License".
  23. If not, write to the Free Software Foundation, 675 Mass Ave,
  24. Cambridge, MA 02139, USA.
  25.  
  26. \**********************************************************************/
  27.  
  28. #include "sfx init.h"
  29. #include "sfx main.h"
  30. #include "sfx environment.h"
  31. #include "notify.h"
  32. #include "ShutDown.h"
  33.  
  34. Handle            initHandle;            /* handle to main init code */
  35. THz                saveZone;
  36.  
  37. void __GetA4(void)
  38. {
  39.     asm {
  40.         bsr.s    @1
  41.         dc.l    0            ;  store A4 here
  42. @1        move.l    (sp)+,a1
  43.     }
  44. }
  45.  
  46. /* this be the init startup install routine thing */
  47. void main(void)
  48. {
  49.     OSErr            isHuman;
  50.     int                resultCode;
  51.     
  52.     RememberA0();
  53.     SetUpA4();
  54.     
  55.     PrepareEnvironment();
  56.     
  57.     asm
  58.     {
  59.         movea.l            a4, a0
  60.         RecoverHandle
  61.         move.l            a0, initHandle
  62.     }
  63.     if(isHuman = MemError())
  64.     {
  65.         StartupError();
  66.     }
  67.     else
  68.     {
  69.         HLock(initHandle);
  70.         HNoPurge(initHandle);
  71.         
  72.         DoSetup();
  73.         StartupGood();
  74.     }
  75.     
  76.     RestoreEnvironment();
  77.     
  78.     RestoreA4();
  79. }
  80.  
  81. void DoSetup(void)
  82. {
  83.     ShutDwnInstall((ProcPtr)&sfxMain, sdOnDrivers+sdOnPowerOff);
  84. }
  85.